package com.hsjk.szwj.module.train.controller.admin;

import com.hsjk.szwj.framework.common.pojo.CommonResult;
import com.hsjk.szwj.framework.common.pojo.PageResult;
import com.hsjk.szwj.module.train.controller.admin.vo.AdminCheckoutOrderUpdateReqVO;
import com.hsjk.szwj.module.train.controller.admin.vo.AdminMemberCheckoutOrderPageReqVO;
import com.hsjk.szwj.module.train.controller.admin.vo.AdminMemberCheckoutOrderPageRespVO;
import com.hsjk.szwj.module.train.service.ICheckoutOrderService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

import static com.hsjk.szwj.framework.common.pojo.CommonResult.success;

/**
 * @author chenjiawei
 * @desc
 * @Date 2023/09/12 23:47
 **/
@Tag(name = "后台管理 - 结算单相关接口")
@RestController
@RequestMapping("/train/checkout-order")
@Validated
@Slf4j
public class AdminCheckoutOrderController {
    @Resource
    private ICheckoutOrderService checkoutOrderService;

    @PostMapping("/page")
    @Operation(summary = "用户结算单分页列表")
    @PreAuthorize("@ss.hasPermission('train:checkout-order:query')")
    public CommonResult<PageResult<AdminMemberCheckoutOrderPageRespVO>> memberCheckoutOrderPage(@RequestBody @Valid
                                                                                                AdminMemberCheckoutOrderPageReqVO reqVO) {
        return success(checkoutOrderService.memberCheckoutOrderPage(reqVO));
    }

    @PostMapping("/update-status")
    @Operation(summary = "结算单状态更新")
    @PreAuthorize("@ss.hasPermission('train:checkout-order:update')")
    public CommonResult<Boolean> updateStatus(@RequestBody @Valid AdminCheckoutOrderUpdateReqVO reqVO) {
        return success(checkoutOrderService.checkoutOrderUpdate(reqVO));
    }

}
